import React, { memo } from "react";
// import PropTypes from "prop-types";
import PaginationWrapper from "./style";
import { Pagination } from "antd";
import { useDispatch, useSelector } from "react-redux";
import { fetchEntireRoomListAction } from "@/store/modules/entire/actionCreator";
const EntirePagination = memo(function EntirePagination(props) {
  const dispatch = useDispatch();

  const { currentPage, totalCount, pageList } = useSelector((state) => {
    return {
      currentPage: state.entire.currentPage,
      totalCount: state.entire.totalCount,
      pageList: state.entire.pageList,
    };
  });
  const size = 20;
  const startPage = currentPage * size + 1;
  const endPage = currentPage * size + size;

  function pageChange(page, size) {
    // dispatch(changeCurrentPageAction(page - 1));
    window.scrollTo(0, 0);
    dispatch(fetchEntireRoomListAction(page - 1));
  }
  return (
    <PaginationWrapper>
      {!!pageList.length && (
        <div className="inner">
          <Pagination onChange={pageChange} total={totalCount} />
          <div className="desc">
            第{startPage}-{endPage}房源, 共超过{totalCount}个
          </div>
        </div>
      )}
    </PaginationWrapper>
  );
});

// EntirePagination.propTypes = {};

export default EntirePagination;
